<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   海纳百川 有容乃大：SparkR与Docker的机器学习实战  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/23290.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466460662: Accept with keywords: (title(0.25):Spark,有容乃大,数盟,社区, topn(0.4):容器,社区,联系,初始化,数盟,hadoop,行业资讯,R语言,作者,数据挖掘,前文,Python,职业规划,分布式计算,基础架构,文章,工程化,Spark,数据,部署,步骤,回归,有容乃大,算法,镜像,spark,逻辑,编程语言,错误率,分布式).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    海纳百川 有容乃大：SparkR与Docker的机器学习实战
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    海纳百川 有容乃大：SparkR与Docker的机器学习实战 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,77] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech/devl">
       编程语言
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/23290.html">
          海纳百川 有容乃大：SparkR与Docker的机器学习实战
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          560 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech/devl" rel="category tag">
          编程语言
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <p>
        <img src="http://www.afenxi.com/wp-content/uploads/2016/03/1459208296.jpg"/>
       </p>
       <p>
        <em>
         题图为美国尼米兹核动力航空母舰
        </em>
       </p>
       <h2 id="articleHeader0">
        介绍
       </h2>
       <p>
        大数据时代，我们常常面对海量数据而头疼。作为学统计出身的人，我们想折腾大数据但又不想学习Hadoop或者Java，我们更倾向于把精力放在建模和算法设计上，SparkR和Docker的完美结合，让R的计算直接从一架战斗机的当兵作战华丽转变为一个航空母舰战斗群！不仅仅简化了分布式计算的操作，还简化了安装部署的环节，我们只几乎不需要做什么改动就可以直接运用R中的data frame进行分布式的计算。
       </p>
       <h2 id="articleHeader1">
        什么是SparkR
       </h2>
       <p>
        参考前文
        <a href="https://segmentfault.com/a/1190000004448995" target="_blank">
         打造大数据产品：Shiny的Spark之旅
        </a>
        ，我们可以知道，SparkR是一个为R提供了轻量级的Spark前端的R包。 SparkR提供了一个分布式的data frame数据结构，解决了 R中的data frame只能在单机中使用的瓶颈，它和R中的data frame 一样支持许多操作，比如select,filter,aggregate等等。（类似dplyr包中的功能）这很好的解决了R的大数据级瓶颈问题。 SparkR也支持分布式的
        <a href="http://www.afenxi.com/topic/machinelearning" target="_blank" title="查看更多关于机器学习的文章">
         机器学习
        </a>
        算法，比如使用MLib机器学习库。
       </p>
       <h2 id="articleHeader2">
        什么是Docker
       </h2>
       <p>
        参考前文
        <a href="https://segmentfault.com/a/1190000003878165" target="_blank">
         打造数据产品的快速原型：Shiny的Docker之旅
        </a>
        ，我们也可以知道，Docker是一种类似于虚拟机的技术，主要解决标准化快速部署的问题，在Docker中安装的软件和主机中的软件可以完全隔离，并通过Daocloud或者hub.docker.com等云服务快速建立Docker仓库，快速复用Docker镜像。Docker已经不仅仅是DevOps人员手中的神器了，每一个开发者都应该学会如何使用Docker。
       </p>
       <p>
        <img src="http://www.afenxi.com/wp-content/uploads/2016/03/1459208452.jpg"/>
       </p>
       <h2 id="articleHeader3">
        为什么要结合SparkR和Docker
       </h2>
       <p>
        SparkR的精髓在于分布式计算，而Docker的精髓在于标准容器的拓展性，SparkR和Docker的组合充分结合了二者各自的优点，将分布式应用底层化繁为简，为高层计算直接暴露接口，给科学计算节省了大量时间。
       </p>
       <h2 id="articleHeader4">
        部署
       </h2>
       <p>
        本文将通过Docker讲解如何快速部署SparkR－RStudio容器，并通过一些简单的机器学习例子展示如何使用这个航母级别的组合拳。
       </p>
       <h3 id="articleHeader5">
        步骤一：安装Docker和Daocloud
       </h3>
       <p>
        由于国内的镜像质量不够高，国外的镜像下载速度比较慢，出于试验的考虑，建议大家可以尝试使用
        <a href="https://dashboard.daocloud.io/mirror" target="_blank">
         Daocloud的镜像加速服务
        </a>
        。
       </p>
       <p>
        <img src="http://www.afenxi.com/wp-content/uploads/2016/03/1459208455.png"/>
       </p>
       <p>
        首先，我们需要在Daocloud注册一个账号，然后选择镜像加速，根据
        <a href="https://dashboard.daocloud.io/nodes/new" target="_blank">
         指示
        </a>
        选择主机并安装Docker和Daocloud加速器。
       </p>
       <h3 id="articleHeader6">
        步骤二：安装Spark－RStudio
       </h3>
       <p>
        感谢
        <a href="https://github.com/vinicius85/docker/tree/master/sparkr-rstudio" target="_blank">
         vinicius85 在GitHub上的开源贡献
        </a>
        ，为我们已经做好了 Spark1.6+R＋RStduio的镜像，我们利用daocloud加速拉取镜像。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576869f46d5c2686194353" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           Python
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          dao pull vinicius85/spark-rstudio
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576869f46d5c2686194353-1">
               1
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576869f46d5c2686194353-1">
               <span class="crayon-e">
                dao
               </span>
               <span class="crayon-e">
                pull
               </span>
               <span class="crayon-v">
                vinicius85
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                spark
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-v">
                rstudio
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0144 seconds] -->
       <p>
       </p>
       <p>
        以daemon形式运行容器，暴露Rstudio－server默认的8787端口, 并持久化docker内的/srv目录下的所有文件作为通讯。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576869f46d5d3981806475" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           Python
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          docker run -d -v /home/docker:/srv -p 8787:8787 --name sparkrstudio vinicius85/sparkr-rstudio
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576869f46d5d3981806475-1">
               1
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576869f46d5d3981806475-1">
               <span class="crayon-e">
                docker
               </span>
               <span class="crayon-v">
                run
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-v">
                d
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-v">
                v
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                home
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                docker
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                srv
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-i">
                p
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                8787
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-cn">
                8787
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                --
               </span>
               <span class="crayon-e">
                name
               </span>
               <span class="crayon-e">
                sparkrstudio
               </span>
               <span class="crayon-v">
                vinicius85
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                sparkr
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-v">
                rstudio
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0081 seconds] -->
       <p>
       </p>
       <h3 id="articleHeader7">
        步骤三：配置RStudio登陆账号
       </h3>
       <p>
        参考前文
        <a href="https://segmentfault.com/a/1190000004442134" target="_blank">
         R语言工程化实践：RStudio Server环境快速配置教程
        </a>
       </p>
       <p>
        <code>
         docker exec -d sparkrstudio bash
        </code>
        命令表示以daemon形式执行容器中的shell脚本
       </p>
       <p>
        我们设置一下RStudio－Server的账号密码
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576869f46d5da153329980" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           Python
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          docker exec -d sparkrstudio bash adduser harryzhu # 设置新用户名
docker exec -d sparkrstudio bash passwd harryzhu # 设置该用户的密码
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576869f46d5da153329980-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5da153329980-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576869f46d5da153329980-1">
               <span class="crayon-e">
                docker
               </span>
               <span class="crayon-r">
                exec
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-i">
                d
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                sparkrstudio
               </span>
               <span class="crayon-e">
                bash
               </span>
               <span class="crayon-e">
                adduser
               </span>
               <span class="crayon-v">
                harryzhu
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                # 设置新用户名
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5da153329980-2">
               <span class="crayon-e">
                docker
               </span>
               <span class="crayon-r">
                exec
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-i">
                d
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                sparkrstudio
               </span>
               <span class="crayon-e">
                bash
               </span>
               <span class="crayon-e">
                passwd
               </span>
               <span class="crayon-v">
                harryzhu
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                # 设置该用户的密码
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0017 seconds] -->
       <p>
       </p>
       <h3 id="articleHeader8">
        步骤四：登陆RStudio
       </h3>
       <p>
        <code>
         ifconfig
        </code>
        命令可以查看到Docker当前的IP地址，透过这个IP，我们可以访问到RStudio－Server。
       </p>
       <p>
        比如：
       </p>
       <p>
        <img src="http://www.afenxi.com/wp-content/uploads/2016/03/1459208459.png"/>
       </p>
       <p>
        查看资源占用情况
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576869f46d5e2198982973" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           Python
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          docker stats sparkrstudio
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576869f46d5e2198982973-1">
               1
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576869f46d5e2198982973-1">
               <span class="crayon-e">
                docker
               </span>
               <span class="crayon-e">
                stats
               </span>
               <span class="crayon-v">
                sparkrstudio
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0108 seconds] -->
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576869f46d5e8825583212" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           Python
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O               BLOCK I/O
sparkrstudio        4.50%               481.3 MB / 5.039 GB   9.55%               133.6 kB / 117.4 kB   3.252 MB / 135.2 kB
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576869f46d5e8825583212-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5e8825583212-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576869f46d5e8825583212-1">
               <span class="crayon-e">
                CONTAINER
               </span>
               <span class="crayon-v">
                CPU
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                %
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                MEM
               </span>
               <span class="crayon-v">
                USAGE
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                LIMIT
               </span>
               <span class="crayon-v">
                MEM
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                %
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                NET
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                I
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-i">
                O
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                BLOCK
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                I
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-i">
                O
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5e8825583212-2">
               <span class="crayon-i">
                sparkrstudio
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                4.50
               </span>
               <span class="crayon-o">
                %
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                481.3
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                MB
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                5.039
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                GB
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                9.55
               </span>
               <span class="crayon-o">
                %
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                133.6
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                kB
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                117.4
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                kB
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3.252
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                MB
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                135.2
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                kB
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0154 seconds] -->
       <p>
       </p>
       <h2 id="articleHeader9">
        机器学习示例：
       </h2>
       <p>
        <img src="http://www.afenxi.com/wp-content/uploads/2016/03/1459208460.png"/>
       </p>
       <p>
        出于演示的考虑，这里引用并稍微改进了
        <a href="http://rpubs.com/tcosta/sparkr-glm" target="_blank">
         tcosta 完成的一个逻辑回归的例子
        </a>
        ：
       </p>
       <h3 id="articleHeader10">
        初始化
       </h3>
       <p>
        使用SparkR之前，我们需要确定，我们的容器内存要在2G以上，如果用AWS的乞丐版套装，马上就会报内存不足的错误。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576869f46d5ee860434048" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           Python
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          Error in sparkR.init(master = "local") :
   JVM is not ready after 10 seconds
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576869f46d5ee860434048-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5ee860434048-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576869f46d5ee860434048-1">
               <span class="crayon-e">
                Error
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sparkR
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                init
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                master
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "local"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5ee860434048-2">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                JVM
               </span>
               <span class="crayon-st">
                is
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                not
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                ready
               </span>
               <span class="crayon-i">
                after
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                10
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                seconds
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0108 seconds] -->
       <p>
       </p>
       <p>
        如果内存不足，可以退出docker并且在虚拟机中重新提高docker的内存和cpu的配置。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576869f46d5f4943848415" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           Python
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          # 配置环境变量
Sys.setenv(SPARK_HOME="/opt/spark-1.6.0-bin-hadoop2.6")
 
.libPaths(c(file.path(Sys.getenv("SPARK_HOME"), "R", "lib"), .libPaths()))
 
Sys.setenv(JAVA_HOME="/usr/lib/jvm/java-8-oracle/")

# 加载 SparkR包
library(SparkR)
 
# 初始化RRD
sc &lt;- sparkR.init(master = "local")
sqlContext &lt;- sparkRSQL.init(sc)

# 创建DataFrame
mtcarsDF &lt;- createDataFrame(sqlContext, mtcars)
head(mtcarsDF)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576869f46d5f4943848415-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5f4943848415-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d5f4943848415-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5f4943848415-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d5f4943848415-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5f4943848415-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d5f4943848415-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5f4943848415-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d5f4943848415-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5f4943848415-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d5f4943848415-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5f4943848415-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d5f4943848415-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5f4943848415-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d5f4943848415-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5f4943848415-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d5f4943848415-17">
               17
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576869f46d5f4943848415-1">
               <span class="crayon-c">
                # 配置环境变量
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5f4943848415-2">
               <span class="crayon-k ">
                Sys
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                setenv
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                SPARK_HOME
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "/opt/spark-1.6.0-bin-hadoop2.6"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d5f4943848415-3">
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5f4943848415-4">
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                libPaths
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                c
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-k ">
                file
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                path
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-k ">
                Sys
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                getenv
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "SPARK_HOME"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "R"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "lib"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                libPaths
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d5f4943848415-5">
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5f4943848415-6">
               <span class="crayon-k ">
                Sys
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                setenv
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                JAVA_HOME
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "/usr/lib/jvm/java-8-oracle/"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d5f4943848415-7">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5f4943848415-8">
               <span class="crayon-c">
                # 加载 SparkR包
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d5f4943848415-9">
               <span class="crayon-e">
                library
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                SparkR
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5f4943848415-10">
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d5f4943848415-11">
               <span class="crayon-c">
                # 初始化RRD
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5f4943848415-12">
               <span class="crayon-v">
                sc
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sparkR
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                init
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                master
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "local"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d5f4943848415-13">
               <span class="crayon-v">
                sqlContext
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sparkRSQL
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                init
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                sc
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5f4943848415-14">
              </div>
              <div class="crayon-line" id="crayon-576869f46d5f4943848415-15">
               <span class="crayon-c">
                # 创建DataFrame
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5f4943848415-16">
               <span class="crayon-v">
                mtcarsDF
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                createDataFrame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                sqlContext
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mtcars
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d5f4943848415-17">
               <span class="crayon-e">
                head
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mtcarsDF
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0274 seconds] -->
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576869f46d5fa358059850" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           Python
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          mpg cyl disp  hp drat    wt  qsec vs am gear carb
1 21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
2 21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
3 22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
4 21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
5 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
6 18.1   6  225 105 2.76 3.460 20.22  1  0    3    1
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576869f46d5fa358059850-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5fa358059850-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d5fa358059850-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5fa358059850-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d5fa358059850-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d5fa358059850-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d5fa358059850-7">
               7
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576869f46d5fa358059850-1">
               <span class="crayon-e">
                mpg
               </span>
               <span class="crayon-e">
                cyl
               </span>
               <span class="crayon-e">
                disp
               </span>
               <span class="crayon-e">
                hp
               </span>
               <span class="crayon-e">
                drat
               </span>
               <span class="crayon-e">
                wt
               </span>
               <span class="crayon-e">
                qsec
               </span>
               <span class="crayon-e">
                vs
               </span>
               <span class="crayon-e">
                am
               </span>
               <span class="crayon-e">
                gear
               </span>
               <span class="crayon-i">
                carb
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5fa358059850-2">
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                21.0
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                6
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                160
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                110
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3.90
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2.620
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                16.46
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                4
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                4
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d5fa358059850-3">
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                21.0
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                6
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                160
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                110
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3.90
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2.875
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                17.02
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                4
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                4
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5fa358059850-4">
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                22.8
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                4
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                108
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                93
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3.85
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2.320
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                18.61
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                4
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d5fa358059850-5">
               <span class="crayon-cn">
                4
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                21.4
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                6
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                258
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                110
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3.08
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3.215
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                19.44
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d5fa358059850-6">
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                18.7
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                8
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                360
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                175
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3.15
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3.440
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                17.02
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d5fa358059850-7">
               <span class="crayon-cn">
                6
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                18.1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                6
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                225
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                105
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2.76
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3.460
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                20.22
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0346 seconds] -->
       <p>
       </p>
       <h3 id="articleHeader11">
        逻辑回归
       </h3>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576869f46d601154417673" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           Python
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          model &lt;- glm(vs ~ mpg + disp + hp + wt , data = mtcarsDF, family = "binomial")# 逻辑回归
# model &lt;- glm(vs ~ mpg + disp + hp + wt , data = mtcarsDF, family = "gaussian")# 线性回归
predictions &lt;- predict(model, newData = mtcarsDF )
modelPrediction &lt;- select(predictions, "vs", "prediction")
head(modelPrediction)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576869f46d601154417673-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d601154417673-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d601154417673-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d601154417673-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d601154417673-5">
               5
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576869f46d601154417673-1">
               <span class="crayon-v">
                model
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                glm
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                vs
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ~
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mpg
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                disp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                hp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                wt
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mtcarsDF
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                family
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "binomial"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-c">
                # 逻辑回归
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d601154417673-2">
               <span class="crayon-c">
                # model &lt;- glm(vs ~ mpg + disp + hp + wt , data = mtcarsDF, family = "gaussian")# 线性回归
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d601154417673-3">
               <span class="crayon-v">
                predictions
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                predict
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                model
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                newData
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                mtcarsDF
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d601154417673-4">
               <span class="crayon-v">
                modelPrediction
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-k ">
                select
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                predictions
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "vs"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "prediction"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d601154417673-5">
               <span class="crayon-e">
                head
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                modelPrediction
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0178 seconds] -->
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576869f46d607104197296" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           Python
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          vs prediction
1  0 0.58006945
2  0 0.64060709
3  1 0.72468718
4  1 0.47803842
5  0 0.06070972
6  1 0.54994276
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576869f46d607104197296-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d607104197296-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d607104197296-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d607104197296-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d607104197296-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d607104197296-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d607104197296-7">
               7
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576869f46d607104197296-1">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                vs
               </span>
               <span class="crayon-i">
                prediction
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d607104197296-2">
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.58006945
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d607104197296-3">
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.64060709
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d607104197296-4">
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.72468718
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d607104197296-5">
               <span class="crayon-cn">
                4
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.47803842
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d607104197296-6">
               <span class="crayon-cn">
                5
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.06070972
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d607104197296-7">
               <span class="crayon-cn">
                6
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0.54994276
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0113 seconds] -->
       <p>
       </p>
       <h3 id="articleHeader12">
        模型评估
       </h3>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576869f46d60c140565949" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           Python
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          # error变量: 观测值和预测值的差值
modelPrediction$error &lt;- abs(modelPrediction$vs - modelPrediction$prediction)
 
# modelPrediction 现在对 SQLContext 是可见的
registerTempTable(modelPrediction, "modelPrediction")
 
num_errors &lt;- sql(sqlContext, "SELECT count(error) FROM modelPrediction WHERE error = 1")
total_errors &lt;- sql(sqlContext, "SELECT count(error) FROM modelPrediction")
 
# 模型错误率
training_acc &lt;- collect(num_errors) / collect(total_errors)
training_acc
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576869f46d60c140565949-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d60c140565949-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d60c140565949-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d60c140565949-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d60c140565949-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d60c140565949-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d60c140565949-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d60c140565949-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d60c140565949-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d60c140565949-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576869f46d60c140565949-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d60c140565949-12">
               12
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576869f46d60c140565949-1">
               <span class="crayon-c">
                # error变量: 观测值和预测值的差值
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d60c140565949-2">
               <span class="crayon-v">
                modelPrediction
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                error
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-k ">
                abs
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                modelPrediction
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                vs
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                modelPrediction
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                prediction
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d60c140565949-3">
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d60c140565949-4">
               <span class="crayon-c">
                # modelPrediction 现在对 SQLContext 是可见的
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d60c140565949-5">
               <span class="crayon-e">
                registerTempTable
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                modelPrediction
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "modelPrediction"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d60c140565949-6">
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d60c140565949-7">
               <span class="crayon-v">
                num_errors
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                sql
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                sqlContext
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "SELECT count(error) FROM modelPrediction WHERE error = 1"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d60c140565949-8">
               <span class="crayon-v">
                total_errors
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                sql
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                sqlContext
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "SELECT count(error) FROM modelPrediction"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d60c140565949-9">
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d60c140565949-10">
               <span class="crayon-c">
                # 模型错误率
               </span>
              </div>
              <div class="crayon-line" id="crayon-576869f46d60c140565949-11">
               <span class="crayon-v">
                training_acc
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                collect
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                num_errors
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                collect
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                total_errors
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d60c140565949-12">
               <span class="crayon-v">
                training_acc
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0156 seconds] -->
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576869f46d612679558445" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          &lt;span class="hljs-title"&gt;&lt;span class="pln"&gt;_c0&lt;/span&gt;&lt;/span&gt;
&lt;span class="hljs-number"&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;/span&gt;   &lt;span class="hljs-number"&gt;&lt;span class="lit"&gt;0&lt;/span&gt;&lt;/span&gt;
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576869f46d612679558445-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576869f46d612679558445-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576869f46d612679558445-1">
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "hljs-title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "pln"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                _c0
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576869f46d612679558445-2">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "hljs-number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "lit"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "hljs-number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "lit"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0107 seconds] -->
       <p>
       </p>
       <h2 id="articleHeader13">
        参考资料
       </h2>
       <ul>
        <li>
         <a href="https://segmentfault.com/a/1190000003878165">
          [原]打造数据产品的快速原型：Shiny的Docker之旅
         </a>
        </li>
        <li>
         <a href="https://segmentfault.com/a/1190000004442134" target="_blank">
          [原]R语言工程化实践：RStudio Server环境快速配置教程
         </a>
        </li>
        <li>
         <a href="https://segmentfault.com/a/1190000004448995">
          [译]打造大数据产品：Shiny的Spark之旅
         </a>
        </li>
        <li>
         <a href="http://rpubs.com/tcosta/sparkr-glm" target="_blank">
          Tiago Vinícius: SparkR 1.5 MLlib Logistic Regression Example
         </a>
        </li>
        <li>
         <a href="http://blog.revolutionanalytics.com/2015/06/sparkr-announcement.html" target="_blank">
          SparkR: Distributed data frames with Spark and R
         </a>
        </li>
        <li>
         <a href="http://amplab-extras.github.io/SparkR-pkg/" target="_blank">
          SparkR R frontend for Spark
         </a>
        </li>
        <li>
         <a href="http://www.chinacloud.cn/upload/2015-07/15072107172253.pdf" target="_blank">
          刘志强, et al. “基于 SparkR 的分类算法并行化研究.” Journal of Frontiers of Computer Science and Technology 9.11 (2015): 1281-1294.
         </a>
        </li>
        <li>
         <a href="http://www.r-bloggers.com/lang/chinese/1131" target="_blank">
          用Parallel和foreach包玩转并行计算
         </a>
        </li>
       </ul>
       <blockquote>
        <p>
         作为分享主义者(sharism)，本人所有互联网发布的图文均遵从CC版权，转载请保留作者信息并注明作者 Harry Zhu 的 FinanceR专栏：
         <a href="https://segmentfault.com/blog/harryprince">
          https://segmentfault.com/blog/harryprince
         </a>
         ，如果涉及源代码请注明GitHub地址：
         <a href="https://github.com/harryprince" target="_blank">
          https://github.com/harryprince
         </a>
         。微信号: harryzhustudio  商业使用请联系作者。
        </p>
       </blockquote>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/24678.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/20140917125452915416-216x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24678.html" rel="bookmark" title="python3中的正则模块">
         python3中的正则模块
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24675.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/t015b337bd75d9ef893-161x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24675.html" rel="bookmark" title="注释是恶魔，请不要再写一行注释">
         注释是恶魔，请不要再写一行注释
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24660.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/u16130037972892789947fm21gp0-300x157.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24660.html" rel="bookmark" title="如何从Github上轻松安装R包">
         如何从Github上轻松安装R包
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24654.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/df53fac99fc53ba5a90666abcca25e6d_b-267x200.png"/>
        </a>
        <a class="link" href="http://dataunion.org/24654.html" rel="bookmark" title="简单形象又有趣地说说强大的神经网络">
         简单形象又有趣地说说强大的神经网络
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F23290.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/23290.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/23290.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>